//
//  ZYStatusFrame.m
//  山寨微博
//
//  Created by 张亚 on 16/1/20.
//  Copyright © 2016年 zhangya. All rights reserved.
//

#import "ZYStatusFrame.h"
#import "ZYStatuse.h"

#define NAMEVIEW_FONT [UIFont systemFontOfSize:15]

@implementation ZYStatusFrame


- (CGSize)sizeWithText:(NSString *)text font:(UIFont *)font maxSize:(CGSize)maxSize{
    NSDictionary *  attrs = @{NSFontAttributeName : font};
    return [text boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:attrs context:nil].size;
}

- (void)setStatus:(ZYStatuse *)status{
    _status = status;
    //间距
    CGFloat padding = 10;
    //头像
//    CGFloat iconX = padding;
//    CGFloat iconY = padding;
//    CGFloat iconW = 30;
//    CGFloat iconH = 30;
//    _iconF = CGRectMake(iconX, iconY, iconW, iconH);
//    
//    //昵称
//    CGFloat nameX = CGRectGetMaxX(_iconF) + padding;
//
//    CGSize nameSize = [self sizeWithText:self.status.name font:NAMEVIEW_FONT maxSize:CGSizeMake(MAXFLOAT, CGFLOAT_MAX)];
//    CGFloat nameY = iconX + (iconH - nameSize.height) * 0.5;
//    CGFloat nameW = nameSize.width;
//    CGFloat nameH = nameSize.height;
//    _nameF = CGRectMake(nameX, nameY, nameW, nameH);
//    
//    //会员图标
//    CGFloat vipX = CGRectGetMaxX(_nameF) + padding;
//    CGFloat vipY = nameY;
//    CGFloat vipW = 15;
//    CGFloat vipH = 15;
//    _vipF = CGRectMake(vipX, vipY, vipW, vipH);
    
    //正文
//    CGFloat textX = iconX;
    //    CGFloat textY = CGRectGetMaxY(_iconF) + padding;
    CGFloat textX = 0;
    CGFloat textY = 0;
    
    CGSize textSize = [self sizeWithText:self.status.text font:NAMEVIEW_FONT maxSize:CGSizeMake(300, MAXFLOAT)];
    _textF = CGRectMake(textX, textY, textSize.width, textSize.height);
    
    //配图
    if (self.status.picture) {
        CGFloat pictureX = SCREEN_WIDTH / 2 - 100;
        CGFloat pictureY = CGRectGetMaxY(_textF) + padding;
        CGFloat pictureW = 200;
        CGFloat pictureH = 200;
        _pictureF = CGRectMake(pictureX, pictureY, pictureW, pictureH);
        
        _cellHeight = CGRectGetMaxY(_pictureF) + padding;
    }else{
        _cellHeight = CGRectGetMaxY(_textF) + padding;
        
    }
    


}

@end
